import {createBrowserRouter} from 'react-router-dom'
import { lazy } from 'react'
import App from '../App'

// 一级
const Home =lazy(()=>import('../pages/home/Index'))
// 二级
const Index = lazy(()=>import('../pages/index/Index'))
const Class = lazy(()=>import('../pages/class/Index'))

// 二级
export const homerouter = [
    {
        path:'/home/index',
        element:<Index></Index>,
        title:'首页'
    },
    {
        path:'/home/class',
        element:<Class></Class>,
        title:'分类'
    }
]

// 一级
const router = createBrowserRouter([
    {
        path:'/',
        element:<App></App>,
        children:[
            {
                index:true,
                element:<Home></Home>,
            },
            {
                path:'/home',
                element:<Home></Home>,
                children:homerouter
            }
        ]
    }
])
export default router